package co.com.services.datosmaestro;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.DatosMaestroDTO;
import co.com.smart.session.DelegateContextEJB;

@Path("/SmartDatosMaestroService")
public class DatosMaestroService {
	@GET
	@Path("/getAllDatosMaestro")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getDatosMaestro() throws NamingException{
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().consultarAllDatosMaestro())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
	
	@POST
	@Path("/getDatosMaestroId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getDatosMaestroId(DatosMaestroDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().consultarDatosMaestroId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setDatosMaestro")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setDatosMaestro( DatosMaestroDTO json){ 
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().insertarDatosMaestro(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editDatosMaestro")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditDatosMaestro(DatosMaestroDTO json){ 
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().editDatosMaestro(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeDatosMaestro")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveDatosMaestro(DatosMaestroDTO json){ 
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().removeDatosMaestro(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
	
	@POST
	@Path("/filtrardatosmaestroxmaestro")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getFiltrardatosmaestroxmaestro(DatosMaestroDTO json) throws NamingException{
		return Response.ok(DelegateContextEJB.getDatosMaestroBeanLocal().filtrardatosmaestroxmaestro(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
}
